// pages/myPages/setPage/changePassWordPage/changePassWordPage.js
var path ="../../../../image/"
//var CryptoJs = require('../../../../utils/bitcoinTool/CryptoJs.min.js');
var wallet = require('../../../wallet.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    initPassword: '',
    PSW: '',
    showView:true,
    ispassword: true, //是否密文显示 true为密文， false为明文。 
    path:path,
    urlImage:'icon_buxianshixinxi.png' ,
    pswdLang:{}
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
  
  },
  initPassword: function (e) {
    this.setData({
      PSW: e.detail.value
    })
    this.loginBtnClick();
  },
  loginBtnClick: function () {
    var arr=[];
    arr=this.data.PSW;
    console.log(arr)
  
    if (arr.length != 6) {
      this.setData({
        showView: true
      })
    } else {
      this.setData({
        showView: false
      })
    }
  },
  setNewPassWordPage: function (e) {
    if (this.data.showView == false) {
      var val = this.data.PSW
      var password = wallet.MD5jiami(val);
      var pswd = wx.getStorageSync('pswd')
      if (password == pswd) {
        wx.navigateTo({
          url: './setNewPassWordPage/setNewPassWordPage'
        })
      }else{
        wx.showToast({
          title: wx.T.locale == "zh-Hans" ? wx.T.locales['zh-Hans'].originalPwd : wx.T.locales['en'].originalPwd,
          icon: 'none',
          duration: 2000,
          mask: true
        });
      }
      this.setData({
        PSW: '',
        showView:true
      })
    }
  },
  clear:function(){
    this.setData({
      PSW:'',
      showView: true
    })
  },
  ciphertext:function(){
    if (this.data.urlImage == 'icon_buxianshixinxi.png'){
      this.setData({
        urlImage: 'icon_xianshixinxi.png',
        ispassword:false
      })
    }else{
      this.setData({
        urlImage: 'icon_buxianshixinxi.png',
        ispassword: true
      })
    }
    
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.setData({
      pswdLang: wx.T.locale == "zh-Hans" ? wx.T.locales['zh-Hans'] : wx.T.locales['en']
    })
    wx.setNavigationBarTitle({
      title: wx.T.locale == "zh-Hans" ? wx.T.locales['zh-Hans'].changePwd : wx.T.locales['en'].changePwd
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})